package com.lyt.springboot.util.algorithm;

public class S10 {
    public String trans(String s) {
        StringBuilder builder = new StringBuilder();
        String[] s1 = s.split(" ", -1);
        for (int i = s1.length-1; i >=0 ; i--) {
            builder.append(reverse(s1[i]));
            if(i==0) {
                break;
            }
            builder.append(" ");
        }
        return builder.toString();
    }
    public String reverse(String s) {
        StringBuilder res = new StringBuilder();
        for(char c:s.toCharArray()) {
            if(Character.isUpperCase(c)) {
               res.append(Character.toLowerCase(c));
            } else if(Character.isLowerCase(c)) {
                res.append(Character.toUpperCase(c));
            }

        }
        return res.toString();

    }

    public static void main(String[] args) {
        S10 s10 = new S10();
        String trans = s10.trans("hellO  fiefFH er");
        System.out.println(trans);

    }
}
